
<template>
    <div class="home">
      <div class="top">
        船票预定
      </div>
      <div class="home-container">
        <u-swiper :list="bannerList" border-radius="20" height="280"></u-swiper>

        <div class="news-list">
          <u-section title="热门资讯" style="margin: 20rpx 0" sub-title="查看更多" :right="false" color="#FF770F"></u-section>
          <div class="news-item" v-for="item in newsList" :key="item.id">
            <u-image style="border-radius: 20rpx" width="120" height="120" :src="item.post_url"></u-image>
            <div class="news-right">
              <div class="news-title"> {{ item.title }}</div>
              <div class="news-desc"> {{ item.desc }}</div>
              <div class="news-bottom">
                <u-icon name=""></u-icon>
                <span class="news-time">{{ item.create_time }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
</template>
<script>
import { mapGetters } from 'vuex'
export default {
  name: "index",
  data() {
    return {
      bannerList: [],
      newsList: []
    }
  },
  computed: {
    ...mapGetters(['userInfo']),
  },
  onShow() {
    this.initData()
  },
  methods: {
    initData() {
      this.$api.getBannerList().then(res => {
        this.bannerList = res.map(item => {
          return {
            image: item.post_url,
            title: item.name
          }
        })
      })
      this.$api.getBannerList().then(res => {
        this.newsList = res
      })
    }
  }
}
</script>

<style lang="scss">
.home {
  position: relative;
  height: 100%;
  .news-list {
    padding: 20rpx 0;
  }
  .news-item {
    padding: 20rpx;
    border-radius: 20rpx;
    background-color: #ffffff;
    margin-top: 20rpx;
    display: flex;
    .news-right {
      height: 120rpx;
      display: flex;
      flex-direction: column;
      justify-content: space-between;
      flex-grow: 1;
      margin-left: 20rpx;
      .news-title {
        font-size: 28rpx;
        color: #333333;
        font-weight: bold;
      }
      .news-desc {
        font-size: 24rpx;
        color: #666666;
        margin-top: 10rpx;
      }
      .news-bottom {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 10rpx;
        .news-time {
          font-size: 24rpx;
          color: #999999;
        }
      }
    }
  }
  .custom-nav {
    position: fixed;
    top: 20rpx;
    right: 30rpx;
    z-index: 9;
    height: 55rpx;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #F3F3F3;
  }

  .top {
    position: absolute;
    width: 100%;
    left: 0;
    top: 0;
    z-index: 1;
    height: 328rpx;
    background: linear-gradient(0deg, #F3F4F4 0%, #FF9346 27%, #FF770F 43%);
    font-size: 24px;
    color: #ffffff;
    font-weight: bold;
    text-align: center;
    line-height: 140rpx;
  }
}
.home-container {
  height: 100%;
  position: absolute;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  left: 0;
  top: 0;
  width: 100%;
  z-index: 2;
  padding:140rpx 32rpx 40rpx 32rpx;
}
</style>
